﻿using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public static class EditorHelper
{
    [MenuItem("GameObject/CopyPath _F8", priority = -100)]
    static void CopyPath()
    {
        GameObject obj = Selection.activeGameObject;
        if (obj != null)
        {
            string path = obj.name;

            Transform tran = obj.transform.parent;
            while (tran.parent != null)
            {
                path = $"{tran.name}/{path}";
                tran = tran.parent;
            }
            GUIUtility.systemCopyBuffer = path;
        }
    }

    public static string ignoreName = "_ignore";
    public static string ignoreAllName = "_ignoreAll";
    [MenuItem("GameObject/Ignore _F10", priority = -101)]
    static void Ignore()
    {
        foreach (var item in Selection.gameObjects)
        {
            IgnoreOne(item);
        }
    }

    static void IgnoreOne(GameObject obj)
    {
        if (obj != null)
        {
            if (obj.name.EndsWith(ignoreAllName))
            {
                obj.name = obj.name.Replace(ignoreAllName, string.Empty);
            }
            else if (obj.name.EndsWith(ignoreName))
            {
                obj.name = obj.name.Replace(ignoreName, ignoreAllName);
            }
            else
            {
                obj.name += ignoreName;
            }
            EditorUtility.SetDirty(obj);
        }
    }

    [MenuItem("DDZ工具/ResetUserInfo重置账号")]
    static public void ResetUserInfo()
    {
        PlayerPrefs.SetString("plat_username", "");
        PlayerPrefs.SetString("plat_password", "");

        PlayerPrefs.SetString("plat_username_zhubo", "");
        PlayerPrefs.SetString("plat_password_zhubo", "");
        PlayerPrefs.SetString("plat_logintype", "");
        PlayerPrefs.SetInt("read32", 0);
    }
}
